#ifndef STRINGUTILS_H
#define	STRINGUTILS_H

#include <string>
#include <vector>
#include <sstream>

using namespace std;

class NumberFormatException : public exception {
public:
    NumberFormatException(const string &str) {
        ostringstream oss;
        oss << "Bad number: " << str;
        msg = oss.str();
    }

    virtual ~NumberFormatException() throw() {}

    virtual const char* what() const throw() {
        return msg.c_str();
    }
private:
    string msg;
};

class StringUtils {
public:
    static vector<string> split(const string& str, const string& delim = " ");

    static int toInt(const string& str) throw(NumberFormatException);

    StringUtils() {}
    virtual ~StringUtils() {}
};

#endif	/* STRINGUTILS_H */

